package soko.sokoban;

/*
 * Enumerates all possible directions.
 * Namely; left (l) up (u) down (d) right (r).
 */
public enum Direction {

    LEFT("l"),
    UP("u"),
    DOWN("d"),
    RIGHT("r");
    private String c;

	/**
	 * Constructs a new Direction.
	 * 
	 * @param c the char to construct.
	 */
    private Direction(String c) {
        this.c = c;
    }

	/**
	 * Returns a string representation of this Direction.
	 * 
	 * @return the char as a String.
	 */
    @Override
    public String toString() {
        return c;
    }

	/**
	 * Returns the opposite direction of this Direction.
	 * 
	 * @return the opposite direction.
	 */
    public Direction getOpposite() {
        switch (this) {
	  case LEFT:
	      return RIGHT;
	  case UP:
	      return DOWN;
	  case RIGHT:
	      return LEFT;
	  case DOWN:
	      return UP;
	  default:
	      throw new RuntimeException();
        }
    }
}
